import { message } from 'ant-design-vue'
import utils from '@/common/utils/utils'

class ExportButtonMenu {
    constructor() {
        this.title = '导出'
        this.tag = 'button'
    }

    getValue(editor) {
        return 'hello'
    }

    isActive(editor) {
        return false
    }

    isDisabled(editor) { 
        return false
    }

    async exec(editor) {
        if (this.isDisabled(editor)) return
        
        const selectionText = editor.getText().trim()

        if(! selectionText){
            message.warning('请先输入内容')
            return
        }

        const editorContent = editor.getHtml()

        utils.export2Word(editorContent, 'file')
    }
}

export const Menu = ExportButtonMenu

export default {
    key: 'ai-export',
    factory() {
      return new ExportButtonMenu()
    }
}